package
{
      import com.pblabs.components.basic.EventSoundTrigger;
      import com.pblabs.engine.PBE;

      import com.pblabs.engine.entity.IEntity;
      import com.pblabs.engine.entity.PropertyReference;
      import com.pblabs.engine.entity.allocateEntity;
      import com.pblabs.engine.resource.MP3Resource;
      import com.pblabs.rendering2D.IScene2D;
      import com.pblabs.rendering2D.SpriteRenderer;
      import com.pblabs.rendering2D.ui.SceneView;

      import flash.geom.Point;

      // Set the initial size of the application, and define the
      // maximum frame rate
      [SWF(width="640", height="480", frameRate="60")]
      public class EmbeddedResources extends SceneView
      {
            public function EmbeddedResources()
            {
                  // Start the PushButton Engine
                  PBE.startup(this);
                  // Initialize some default PushButton components
                  PBE.initializeScene(this);

                  PBE.addResources(new ResourceDatabase());

                  // Create a component to draw a sprite on the screen
                  var spriteRenderer:SpriteRenderer =
                        new SpriteRenderer();
                  spriteRenderer.fileName = "player.png";
                  spriteRenderer.scene =
                  PBE.lookupComponentByType(
                        "SceneDB", IScene2D) as IScene2D;
                  // Set the position of the shape drawn on the screen
                  spriteRenderer.position = new Point(
                      stage.stageWidth / 2,
                      stage.stageHeight / 2);

                  var soundTrigger:EventSoundTrigger =
                        new EventSoundTrigger();
                  soundTrigger.startSound =
                        PBE.resourceManager.load(
                              "shoot.mp3", MP3Resource) as MP3Resource;

                  var keyboardController:KeyboardControllerComponent =
                      new KeyboardControllerComponent();
                  keyboardController.positionReference =
                      new PropertyReference("@Render.position");

                  // Create an entity to hold the component
                  var entity:IEntity = allocateEntity();
                  // Initialize the Entity with the supplied name
                  entity.initialize("TestEntity");
                  // Add the components to the Entity
                  entity.addComponent(
                        keyboardController, "KeyboardController");
                  entity.addComponent(spriteRenderer, "Render");
                  entity.addComponent(soundTrigger, "Sound");
            }

      }
}
